/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2024-03-06
 * Time: 15:45
 */

class OuterClass {
    public int data1 = 10;
    private int data2 = 20;
    public static int data3 = 30;


    class InnerClass {
        public int data1 = 1111;

        public int data4 = 40;
        private int data5 = 50;
        public static final int data6 = 60;//final修饰的常量 常量是在编译的时候就已经确定了

        public void testInner() {
            System.out.println("testInner");
            //实例内部类 是存在外部类的this的
            System.out.println(OuterClass.this.data1);
            System.out.println(this.data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }

    public void testOuter() {
        InnerClass innerClass = new InnerClass();
        System.out.println(innerClass.data1);
    }

}

class OuterClass2 {
    public int data1 = 10;
    private int data2 = 20;
    public static int data3 = 30;

    /**
     * 1. 如何实例化静态内部类对象
     *
     * 2. 如何在静态内部类当中访问外部类的非静态成员？？
     *
     */
    static class InnerClass2 {
        public int data4 = 40;
        private int data5 = 50;
        public static int data6 = 60;

        public void testInner() {
            System.out.println("testInner()");
            OuterClass2 outerClass2 = new OuterClass2();
            System.out.println(outerClass2.data1);
            System.out.println(outerClass2.data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }
}

class OuterClass3 {
    public void test() {
        class InnerClass {
            public int data1 = 10;

        }
        InnerClass innerClass = new InnerClass();
        System.out.println(innerClass.data1);
    }
}

class Student implements Comparable<Student> {

    @Override
    public int compareTo(Student o) {
        return 0;
    }
}

interface Shape {
    void draw();
}

public class Test {

    public static void main(String[] args) {
        Comparable<Student> comparable = new Student();
        new Comparable<Student>() {

            @Override
            public int compareTo(Student o) {
                return 0;
            }
        };
        int a= 10;
        new Shape() {
            @Override
            public void draw() {
                // a = 99;
                System.out.println("矩形! " + a);
            }
        }.draw();
    }

    public static void main2(String[] args) {
        OuterClass2.InnerClass2 innerClass = new OuterClass2.InnerClass2();
        innerClass.testInner();

    }


    public static void main1(String[] args) {
        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        OuterClass.InnerClass innerClass2 =  new OuterClass().new InnerClass();
        innerClass2.testInner();
        outerClass.testOuter();
    }
}
